-
Notifications
You must be signed in to change notification settings - Fork 69
Always perform a require
prior to analyzing a ns
#321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[refactor-nrepl.analyzer :as sut] | ||
[clojure.test :refer [deftest is]])) | ||
|
||
(deftest ns-ast-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified that if we comment out this PR's main change, this test would fail, complaining about go-loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, you are on a tear 🥇
Great job!
src/refactor_nrepl/analyzer.clj
Outdated
@@ -77,7 +77,8 @@ | |||
(not (util/self-referential? ns))) | |||
;; Use `locking`, because AST analysis can perform arbitrary evaluation. | |||
;; Parallel analysis is not safe, especially as it can perform `require` calls. | |||
(locking core/require-lock | |||
(locking core/require-lock ;; for both `require` and `aj/analyze-ns` | |||
(require ns) ;; ease the work for t.ana |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a general tip with regards to writing comments: have them answer why questions.
Since it's here we can assume that it's needed, but we're still left asking why that is. You could remedy that with a comment like: ;; t.ana sometimes fails to require the needed namespaces on its own
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use this as the comment here:
Performing this require makes it more likely that t.ana will succeed. I believe it's becase require will also require other stuff recursively. t.ana does so in theory as well but it's a bit more rigid.
Thanks for the suggestions! |
Part of #245
Performing this
require
makes it more likely that t.ana will succeed. I believe it's becaserequire
will alsorequire
other stuff recursively. t.ana does so in theory as well but it's a bit more rigid.